package com.baicaoyuan.web.repository;


import com.baicaoyuan.web.model.JzzUserProjectDO;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.Modifying;
import org.springframework.data.jpa.repository.Query;
import org.springframework.stereotype.Repository;

import javax.transaction.Transactional;
import java.util.List;

/**
 * 功能描述：
 *
 * @author 罗富祥
 * 创建时间： 2018/1/4
 * 版权：
 */
@Repository
public interface JzzUserProjectRepository extends JpaRepository<JzzUserProjectDO, Long> {

    JzzUserProjectDO findBySerialNumberAndStatus(String serialNumber, String status);

    List<JzzUserProjectDO> findByUserIdAndStatus(Long userId, String status);

    JzzUserProjectDO findBySerialNumber(String serialNumber);

    @Transactional
    @Modifying
    @Query(value = "update t_jzz_user_project set serial_number = ?1 where serial_number = ?2", nativeQuery = true)
    Integer updateSno(String newSno, String oldSno);
}
